﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Zhaoxi.HeatExchange.Controls
{
    /// <summary>
    /// Pump.xaml 的交互逻辑
    /// </summary>
    public partial class Pump : UserControl
    {
        public Pump()
        {
            InitializeComponent();
        }


        // 定义一个依赖属性,用于后续状态绑定
        public bool IsRunning
        {
            get { return (bool)GetValue(IsRunningProperty); }
            set { SetValue(IsRunningProperty, value); }
        }
        public static readonly DependencyProperty IsRunningProperty =
            DependencyProperty.Register("IsRunning", typeof(bool), typeof(Pump),
                new PropertyMetadata(false, new PropertyChangedCallback(OnIsRunningChanged)));

        private static void OnIsRunningChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var v = bool.Parse(e.NewValue.ToString());
            if (v)
            {
                VisualStateManager.GoToState(d as Pump, "RunState", false);
            }
            else
            {
                VisualStateManager.GoToState(d as Pump, "StopState", false);
            }
        }
    }
}
